package com.zeng.user.mybatis.annotation;

import org.apache.ibatis.plugin.Interceptor;
import org.springframework.beans.factory.config.AbstractFactoryBean;

import java.util.Arrays;

/**
 * @author zyb
 * @date 2021-05-10 21:51
 * @see org.springframework.beans.factory.config.ListFactoryBean
 */
public class InterceptorFactoryBean extends AbstractFactoryBean<Interceptor[]> {

    private Interceptor[] sources;


    @Override
    public Class<?> getObjectType() {
        return Interceptor[].class;
    }

    @Override
    protected Interceptor[] createInstance() throws Exception {
        if (this.sources == null) {
            throw new IllegalArgumentException("'sources' is required");
        }
        return Arrays.copyOf(sources, sources.length);
    }

    public void setSources(Interceptor[] sources) {
        this.sources = sources;
    }
}
